<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'shopcarselect.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<link rel="stylesheet" type="text/css" href="css/common.css">
	<SCRIPT type="text/javascript">
		onerror=function(x,y,z){
			alert(x+"\n"+y+"\n"+z);
		}
		function generateSelect(){
			var amounts=document.getElementsByName("amount");
			for(var i=0;i<amounts.length;i++){
				remainder=parseInt(amounts[i].getAttribute("remainder"));
				curamount=parseInt(amounts[i].getAttribute("curamount"));
				for(var j=1;j<=100&&j<=remainder;j++){
					var theOption = document.createElement("option");
					theOption.innerHTML = j;
					theOption.value = j;
					if(j==curamount) theOption.selected=true;
					amounts[i].appendChild(theOption);
				}
			}
		}
	</SCRIPT>
  </head>
  <body onload="generateSelect()">
    <div class="centerdiv">
    	<table class="leftstyle">
    			<tr>
    				<td colspan="2"><font class="hot">热门推荐：</font></td>
    			</tr>
    			<tr>
    				<td colspan="2">
						<ul>
							<li>穆斯林的葬礼</li>
							<li>乔布斯传</li>
							<li>麦田里的守望者</li>
						</ul>
    				</td>
    			</tr>
    			<tr>
    				<td colspan="2"><font class="hot">友情链接：</font></td>
    			</tr>
    			<tr>
    				<td colspan="2">
						<ul>
							<s:iterator value="#session.linkList">
						    	<li><a href="<s:property value='url' />" target="_top" class="myfont">
						    			<s:property value="site" />
						    		</a>
						    	</li>	
						    </s:iterator>
					
						</ul>
    				</td>
    			</tr>
    			
    	</table>
   		<table class="tablestyle">
   			<tr>
   				<td class="title_font">我的购物车</td>
   			</tr>
   			<tr class="table_title"">
   				<th>书籍封面</th>
   				<th>书籍名称</th>
   				<th>作者</th>
   				<th>分类</th>
   				<th>单价</th>
   				<th>数量</th>
   				<th>处理</th>
   			</tr>
   			<s:if test="%{size==0}">
   				<tr>
   					<td colspan="5">你还没有挑选商品</td>
   					<td><a href="jsp/user/booklist.jsp">返回挑选商品</a></td>
   				</tr>
   			</s:if>
   			<s:else>
   				<s:iterator value="%{shopCarList}">
					<tr align="center">
						<td>
							<img width="80px" height="120px" alt="<s:property value='%{title}' />" src="<s:property value='%{picturePath}' />">
						</td>
						<td>
							<s:property value="title" />
						</td>
						<td>
							<s:property value="author" />
						</td>
						<td>
							<s:property value="typeName" />
						</td>
						<td>
							<s:property value="price" />
						</td>
						<td>
							<select style="width:50px" name="amount" remainder="<s:property value='remainder' />" curamount="<s:property value='amount' />" onchange="location.href='jsp_user_shopcarupdate.action?amount='+this.value+'&bookId='+<s:property value='bookId' /> ">
							</select>
						</td>
						<td>
							<a href="jsp_user_shopcardelete?bookId=<s:property value='bookId' />">删除</a>
						</td>
					</tr>
   				</s:iterator>
   				<tr>
   					<td colspan="4" id="totalmoney" align="right">
   						商品总金额：<s:property value="totalFee"/>
   					</td>
   					<td align="right">
   						<a href="jsp_user_submitorder.action">提交订单</a>
   					</td>
   					<td align="right">
   						<a href="jsp/user/booklist.jsp">返回继续购物</a>
   					</td>
   				</tr>
   			</s:else>
   		</table>
    </div>
  </body>
</html>
